import SwiftUI

struct EventCard: View {
    var image: Image
    var title: String
    var time: String
    var description: String? = nil
    var onTap: (() -> Void)? = nil
    
    var body: some View {
        HStack(spacing: 12) {
            image
                .resizable()
                .aspectRatio(1, contentMode: .fill)
                .frame(width: 56, height: 56)
                .clipped()
                .cornerRadius(10)
            VStack(alignment: .leading, spacing: 4) {
                Text(title)
                    .font(.headline)
                Text(time)
                    .font(.caption)
                    .foregroundColor(.secondary)
                if let description = description {
                    Text(description)
                        .font(.subheadline)
                        .foregroundColor(.secondary)
                        .lineLimit(2)
                }
            }
            Spacer()
        }
        .padding(10)
        .background(Color(.systemBackground))
        .cornerRadius(14)
        .shadow(color: Color.black.opacity(0.05), radius: 2, x: 0, y: 1)
        .onTapGesture { onTap?() }
    }
}

#Preview {
    EventCard(image: Image(systemName: "calendar"), title: "天安门广场", time: "2024-01-14 10:00", description: "北京地标性建筑")
        .padding()
        .frame(width: 320)
} 